package cc.eddic.pratice.programmingparadigms.emp03objlist.impl;

import cc.eddic.pratice.programmingparadigms.*;
import cc.eddic.pratice.programmingparadigms.emp02list.EmployeeList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectComparator;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectList;
import cc.eddic.pratice.programmingparadigms.emp03objlist.ObjectPredicate;

public class EmployeeListZyzImpl extends ObjectList implements EmployeeList {
    public EmployeeListZyzImpl(){
        super();
    }
    public EmployeeListZyzImpl(int capacity){
        super(capacity);
    }

    @Override
    public void add(Employee employee) {
        super.add(employee);
    }

    @Override
    public Employee get(int index) {
        return (Employee) super.get(index);
    }

    public Employee find(EmployeePredicate predicate){
        return (Employee) super.find(new ObjectPredicate(){
            @Override
            public boolean test(Object obj){return predicate.test((Employee)obj);}
        });
    }

    public void sort(EmployeeComparator comparator) {
        super.sort(new ObjectComparator() {
            @Override
            public int compare(Object o1, Object o2) {
                return comparator.compare((Employee) o1, (Employee) o2);
            }
        });
    }

}
